package com.example.smartmedicalsystem.repository;

import com.example.smartmedicalsystem.entity.Doctor;
import com.example.smartmedicalsystem.entity.Schedule;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.time.LocalDate;
import java.util.List;

public interface ScheduleRepository extends JpaRepository<Schedule, Long> {
    List<Schedule> findByDoctorAndScheduleDate(Doctor doctor, LocalDate scheduleDate);

    @Query("SELECT s FROM Schedule s WHERE s.doctor = :doctor AND s.scheduleDate BETWEEN :start AND :end")
    List<Schedule> findByDoctorAndDateRange(
            @Param("doctor") Doctor doctor,
            @Param("start") LocalDate start,
            @Param("end") LocalDate end
    );
    @Query("SELECT s FROM Schedule s " +
            "WHERE s.doctor.department.id = :departmentId " +
            "AND s.scheduleDate = :date")
    List<Schedule> findByDepartmentAndDate(
            @Param("departmentId") Long departmentId,
            @Param("date") LocalDate date
    );
    @Query("SELECT s FROM Schedule s WHERE s.doctor.department.id = :departmentId AND s.scheduleDate = :scheduleDate")
    List<Schedule> findByDoctor_Department_IdAndScheduleDate(Long departmentId, LocalDate scheduleDate);
    @Query("SELECT s FROM Schedule s WHERE s.doctor.department.id = :departmentId")
    List<Schedule> findByDepartmentId(@Param("departmentId") Long departmentId);
}



